<?php
class UserController extends UserBaseController {
	public function quit(){
		$admin=HttpServerManager::getUserServer();
		$admin->quit();
		header("Location: index.html");
	}
	public function home(){
		if(empty($_SESSION['user']['id'])){
			header('location:login.html');
		}
		//若已经完善，不需要跳转
		$where  = array('user_id'=>$_SESSION['user']['id'],'class_status'=>CLASS_STATUS_2);
		$bookCourseDao = HttpDaoManager::getBookCourseDao();
		$data['userCourseCount'] = $bookCourseDao->searchNumber($where);
		$haveClassRecord = $bookCourseDao->searchList($where,'order by id desc ',1);
		$tmp = $this->have($haveClassRecord);
		$data['userData'] = HttpDaoManager::getUserDao()->get($_SESSION['user']['id']);
		$data['haveClassRecord'] = $tmp['list'];
		$data['complaint_type'] = $tmp['complaint_type'];
		$data['collectionList'] = HttpDaoManager::getCollectionDao()->searchList(array('user_id'=>$_SESSION['user']['id']));

		$userBook_filter = array();
		$userBook_filter['user_id'] = $_SESSION['user']['id'];
		$userBook_filter['class_status'] = array(CLASS_STATUS_3,'<>');
		$userBook_filter['book_date'] =array(strtotime(date('Y-m-d')),'>=');
		$data['userBook'] = HttpServerManager::getBookCourseServer()->userBook($userBook_filter,2);

		return array_merge($this->userPublic(),$data);
	}

	public function userPublic($initUrl=array()){
		$include = HttpServerManager::getIndexIncludeServer();
		$data['userTop']  = $include->getUserTop();
		$initUrlLeft ="";
		if(!empty($initUrl)){
			$initUrlLeft =$initUrl['left'];
		}
		$data['userLeft'] = $include->getUserLeft($initUrlLeft);
		$data['userMenu'] = $include->getUserMenu();
		$data['userFoot'] = $include->getUserFoot();
		return $data;
	}
	
	public function userCard(){
		$number=$_POST['number'];
		$password=$_POST['password'];
		$result = array();
	    if (empty($number)) {
	    	$result['success']='fail';
	    	$result['error_code']=ERROR_CODE_ONE;
	    	exit(json_encode($result));
	    }
	    if (empty($password)) {
	    	$result['success']='fail';
	    	$result['error_code']=ERROR_CODE_TWO;
	    	exit(json_encode($result));
	    }		
	    $number="'".$number."'";
        $ticket_info = HttpDaoManager::getTicketDao()->getByNumber($number);
        if(empty($ticket_info)){
        	$result['success']='fail';
        	$result['error_code']=ERROR_CODE_ONE;
        	exit(json_encode($result));
        }
        
		$product = HttpDaoManager::getProductDao()->get($ticket_info['product_id']);
		if($product['type']!=PRODUCT_TYPE_5&&$product['type']!=PRODUCT_TYPE_4&&$product['type']!=PRODUCT_TYPE_7){//卡类型不对
	    	$result['success']='fail';
	    	$result['error_code']=ERROR_CODE_FIVE;
	    	exit(json_encode($result));
		}else{
			$where = array();
			$where['user_id'] = $_SESSION['user']['id'];
			$where['pay_status'] = PAY_STATUS_2;//已购买的用户不能再次使用
			$book_course_info =HttpDaoManager::getOrderDao()->searchList($where);
			if($product['new_user_favour']==1&&!empty($book_course_info)){
				$result['success']='fail';
				$result['error_code']=ERROR_CODE_12;
				exit(json_encode($result));												
			}

			$where = array();
			$where['product_id'] = $product['id'];
			$where['use_user_id'] = $_SESSION['user']['id'];
			$ticket_usered_info = HttpDaoManager::getTicketDao()->searchMutilList($where);
			if($product['new_user_favour']==1&&!empty($ticket_usered_info)){//若是新用户卡，则只能使用一次
				$result['success']='fail';
				$result['error_code']=ERROR_CODE_12;
				exit(json_encode($result));
			}
		}

		$valid_ticket = HttpServerManager::getTicketServer()->validateCardInfo($ticket_info,$password);
		if($valid_ticket!==true){
	    	$result['success']='fail';
	    	$result['error_code']=$valid_ticket;
	    	exit(json_encode($result));
		}
		
		$ticket_log_info =  HttpDaoManager::getTicketLogDao()->getByTicketId($ticket_info['id']);
		$valid_ticket_log = HttpServerManager::getTicketServer()->validateCardLogInfo($ticket_log_info);
		if($valid_ticket_log!==true){
	    	$result['success']='fail';
	    	$result['error_code']=$valid_ticket_log;
	    	exit(json_encode($result));
		}				
		 HttpServerManager::getTicketServer()->useCardInfo($ticket_info);       
		 HttpServerManager::getUserServer()->changeUserAccount($_SESSION['user']['id'],$product,$ticket_log_info);

		 //特殊需求:配合3.19校园行活动
		 if(stripos($ticket_info['number'],'21828')!==false){
		 	$user_id = $_SESSION['user']['id'];
		 	$data['lead_source'] = LEAD_SOURCE_3;
		 	$data['user_kind'] = USER_KIND_ACTIVE_515;
		 	HttpDaoManager::getUserDao()->update($data, $user_id);
		 	
		 }

		 //特殊需求:配合0708校园行活动
		 if(stripos($ticket_info['number'],'100668')!==false){
		 	$user_id = $_SESSION['user']['id'];
		 	$data['lead_source'] = LEAD_SOURCE_4;
		 	$data['user_kind'] = USER_KIND_ACTIVE_708;
		 	HttpDaoManager::getUserDao()->update($data, $user_id);
		 	
		 }
		 
		 $success_card = array('price'=>$product['price'],'type'=>$product['type'],'lesson'=>$product['lesson']);
	 	 $result['success']='success';
	 	 $result['success_card']=$success_card;
    	 $result['error_code']=$valid_ticket_log;
    	 exit(json_encode($result));
	}
	
	public function cardsuccess(){
		$data = $this->userPublic();
		$type = $_GET['type'];
		$times = $_GET['times'];
		if($type=='4'){
			$msg = '充值成功,您已获得次卡类型套餐&nbsp;&nbsp;<font size="6">'.$times.'</font>&nbsp;&nbsp;次上课机会,祝您听课愉快';
		}
		
		if($type=='7'){
			$msg = '充值成功,您已获得包月类型套餐&nbsp;&nbsp;<font size="6">'.$times.'</font>&nbsp;&nbsp;包月卡上课机会,祝您听课愉快';
		}
		if($type=='5'){
			$msg = '充值成功,请查看账户余额';
		}
		$data['msg'] = $msg;
		return $data;
	}
	
	/**
	 * 收藏老师
	 */
	public function collection(){
		HttpServerManager::getCollectionServer()->collection($_SESSION['user']['id'],Common::getPostStrValue('teacherId'));
		echo 1;
		exit ;
	}
	
	/**
	 * 预约
	 */
	public function booking(){
		$book_date = Common::getGetStrValue('book_date');
		$book_time = Common::getGetStrValue('book_time');
		$book_teacher = Common::getGetStrValue('book_teacher');
		
		$where = array();
		$where['date'] = $book_date;
		$where['time'] = $book_time;
		$where['teacher_id'] = $book_teacher;
		$where['confirm_status'] = TEACHER_STATUS_CONFIRMED;
		$where['status'] = TEACHER_CLASS_STATUS_NOTBOOKING;
		$teacherClassInfo =HttpDaoManager::getTeacherStartCourseDao()->searchList($where,'',1);
		if(empty($teacherClassInfo)){
			 $msg = Common::_t('teacher_error');
 			ClassManager::getToos()->msgbox($msg[TEACHER_ERROR_RETRY]);
		}
		
		$teacherClassId = $teacherClassInfo[0]['id'];
		$bookdate  = HttpServerManager::getTeacherStartCourseServer()->userGet($teacherClassId);
		
 		$userData = HttpDaoManager::getUserDao()->get($_SESSION['user']['id']); 
 		if ($bookdate==TEACHER_ERROR_NOE){
 			$msg = Common::_t('teacher_error');
 			ClassManager::getToos()->msgbox($msg[TEACHER_ERROR_NOE]);
 		}
 		$bookCourseServer = HttpServerManager::getBookCourseServer();
 		$userMsg = Common::_t('user_error');
 		//排除同日同时段冲突
 		$exclusive = $bookCourseServer->exclusive($bookdate['date'], $bookdate['time'], $_SESSION['user']['id']);
 		if (!($exclusive===true)){
 			ClassManager::getToos()->msgbox($userMsg[$exclusive]);
 		}
 		
 		//排除同日包月服务冲突
 		$WNMonthlyBooking = $bookCourseServer->WNMonthlyBooking($bookdate['date'],$_SESSION['user']['id']);
 		if($userData['user_class']==0&&$userData['user_experience_class']==0){//没有次卡 判断月卡
	 		// 判断包月预约
	 		if (!($WNMonthlyBooking===true)){
	 			ClassManager::getToos()->msgbox($userMsg[$WNMonthlyBooking]);
	 		}
 		}
 		
 		$userClassType = HttpServerManager::getUserServer()->getUserClassType($_SESSION['user']['id']);
 		
 		if ($userClassType ==USER_ERROR_ONE){
 			ClassManager::getToos()->msgbox($userMsg[USER_ERROR_ONE]);
 		}
 		
 		if ($userClassType['classTypeSpecial']==1){
 			$userClassTypeHtml = '';
 			$userClassTypes = $userClassType['classType'];
 		}else {
 			$classTypeCount = count($userClassType['classType']);
 			$classTypetmp = Common::_t('user_class_type');
 			if ($classTypeCount == 1){
 				$userClassTypes = $userClassType['classType'][0];
 				$userClassTypeHtml = '<dd>预约类型：<em>'.$classTypetmp[$userClassTypes].'</em></dd>';
 			}
 			else{
 				$userClassTypes = '';
 				$option = '';
 				foreach ($userClassType['classType'] as $v){
 					$option = '<option value="'.$v.'">'.$classTypetmp[$v].'</option>'.$option;
 				}
 				$userClassTypeHtml = '<dd>预约类型：<em><select name="userClassTypes" id="userClassTypes">'.$option.'</select></em></dd>';
 			}
 		}
 		
 		$teacherData =  HttpDaoManager::getTeacherDao()->get($bookdate['teacher_id']);
 		$public = $this->userPublic();
 		$time = Common::getTimes();
 		$time=$time[$bookdate['time']]['name'].'-'.$time[$bookdate['time']]['nextName'];
 		$communication = Common::_t('user_communication');
 		$communicationOption = page_modifier_options($communication,$userData['default_communication']); 
 		$data = array(
 			'course_type'           => Common::_t('course_type'),
 			'userTop'               => $public['userTop'],
 			'userLeft'              => $public['userLeft'],
 			'userFoot'              => $public['userFoot'],
 			'userClassType'         => $userClassTypes,
 			'userClassTypeHtml'     => $userClassTypeHtml,
 			'name'                  => $teacherData['name'],
 			'date'                  => date('Y年m月d日',$bookdate['date']),
 			'time'                  => $time,
 			'portrait'              => $teacherData['detail_portrait'],
 			'communicationOption'   => $communicationOption,
 			'default_communication' => $userData['default_communication'],
 			'id'                    => $teacherClassId
 		);
 		
 		$user_communication_info = array('qq'=>$userData['qq'],'skype_id'=>$userData['skype_id'],'phone'=>$userData['phone'],'english_name'=>$userData['english_name'],'real_phone'=>$userData['real_phone']);
 		$data['user_communication_info'] =$user_communication_info;
		$data['today_monthly_booking'] = false;
 		if(!($WNMonthlyBooking===true)){
			$data['today_monthly_booking'] = $WNMonthlyBooking;
 		}
 		return $data;
	}
	
	public function subBooking(){
		$tmp = Common::getPostStrValue('userClassTypes');
		$tmpa= Common::getPostStrValue('userClassType') ;
		$toos = ClassManager::getToos();
		$userClassType = empty($tmp) ? $tmpa : $tmp;
		if (empty($userClassType)){
			$msg = Common::_t('user_error');
			$toos->msgbox($msg[USER_ERROR_THREE]);
		}
		$communication_tools  = Common::getPostStrValue('communication_tools');
		//预约
		/**
		 * id:老师开课id ,userClassType:学生课时类型,type:课程类型,chapter:章节,userId:会员id,message:学生留言,communicationTools:通讯工具
		 */		
		$booking_info = array();
		$booking_info['teacher_class_id'] = Common::getPostStrValue('id');
		$booking_info['user_class_type'] = $userClassType;
		$booking_info['course_type'] = Common::getPostStrValue('course_type_radio');
		$booking_info['chapter_id'] = Common::getPostStrValue('chapter');
		if(isset($booking_info['chapter_id'])&&$booking_info['chapter_id']>0){
			$chapter_info = HttpDaoManager::getChapterDao()->get($booking_info['chapter_id']);
			$booking_info['course_id'] = $chapter_info['course_id'];
			$booking_info['chapter_no'] =  $chapter_info['chater_no'];//写错了
			$booking_info['chapter_name'] = Common::getLangPostValue($chapter_info['name'],$chapter_info['english_name']);
		}

		$booking_info['user_id'] =$_SESSION['user']['id'];
		$booking_info['message'] =Common::getPostStrValue('message');
		$booking_info['communicationTools'] =$communication_tools;


		if($communication_tools==QQ){
			$booking_info['qq'] =Common::getPostStrValue('qq');
		}
		if($communication_tools==SKYPE){
			$booking_info['skype_id'] =Common::getPostStrValue('skype_id');
		}
		
		$user_info = HttpDaoManager::getUserDao()->get($_SESSION['user']['id']);
		$old_user_type = $user_info['user_type'];
		
// 		$booking_info['phone'] =$user_info['phone'];//手机号固定
		//验证平台不能使用
		$booking_info['phone'] = Common::getPostStrValue('phone');//手机号固定
		
		$booking_info['english_name'] = Common::getPostStrValue('english_name');
		
		$booking_info['message'] =Common::getPostStrValue('message');
		
		$tmp = HttpServerManager::getBookCourseServer()->booking($booking_info);
		
		if (!($tmp === true)){
			$msg = Common::_t('user_error');
			$toos->msgbox($msg[$tmp]);
		}
		
		$userData = array();
		//修改用户默认
		if (Common::getPostStrValue('default')=='1'){
			$userData['default_communication'] = $communication_tools;
		}
		
		if($communication_tools==QQ){
			$userData['qq'] =$booking_info['qq'];
		}
		if($communication_tools==SKYPE){
			$userData['skype_id'] =$booking_info['skype_id'];
		}

		$userData['english_name'] =$booking_info['english_name'];
		
		//验证平台不能使用
		$userData['phone'] =$booking_info['phone'];
		$userData['real_phone'] = SMS_SERVER_2;
		//
		
		if($old_user_type==USER_TYPE_NOACTION){
			$userData['user_type'] = USER_TYPE_EXPERIENCE_NOMONEY;
		}
		
		HttpDaoManager::getUserDao()->update($userData, $_SESSION['user']['id']);
		
		header('location:user_booksuccess.html');
		//$toos->msgbox('预约成功','user_book.html');
	}

	public function downloadMaterial(){
		$course = $_POST['course'];
		$chapter = $_POST['chapter'];		
		if(isset($_GET['sa'])&&!empty($_GET['sa'])){
			$url_parameter_sa = $_GET['sa'];
			$url_parameter_up = $_GET['up'];
			$course = Common::decryptUrl($url_parameter_sa);
			$chapter = Common::decryptUrl($url_parameter_up);
		}
		$tmp =HttpServerManager::getCourseServer()->downloadMaterial($chapter,$course);
		$toos  =ClassManager::getToos();
		if ($tmp==USER_ERROR_TWO){
			$msg = Common::_t('user_error');
			exit('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script>alert("'.$msg[USER_ERROR_TWO].'"); document.close();window.close();</script>');
		}
		else{
			$new_file_name="";
			if($tmp!=""){
				$pos= strrpos($tmp,'/');
				$file_head = substr($tmp, 1,$pos);
				$file_name = substr($tmp, $pos+1);
				//$file_name = preg_replace('/\s{2, }| /','%20',$file_name);
				$new_file_name = $file_head.$file_name;
			}
			$toos->download(WEB_DIR.$new_file_name);
		}
	}
	
	
	public function cancellation(){
		$tmp = HttpServerManager::getBookCourseServer()->adminCancellation($_GET['id']);
		$msg = Common::_t('msg');
		if ($tmp===true){
			ClassManager::getToos()->msgbox($msg[MESSAGE_TYPE_6]);
		}
		else{
			ClassManager::getToos()->msgbox($msg[$tmp],'user_home.htm');
		}
	}
	
	public function productList (){
		$data = $this->userPublic();
		$productDao  = HttpDaoManager::getProductDao();
  		$product_monthly_list= $productDao->searchList(array('type'=>PRODUCT_TYPE_1,'status'=>PRODUCT_STATUS_1,'active_type'=>ACTIVE_TYPE_1));
  		$product_data = array();
  		foreach($product_monthly_list as $k=>$v){
  			$product_data[$v['unit']][$v['id']]=$v;
  		}
  		ksort($product_data);
  		$data['product'][PRODUCT_TYPE_1] = $product_data;
  		
  		$product_card_list = $productDao->searchList(array('type'=>PRODUCT_TYPE_2,'status'=>PRODUCT_STATUS_1,'active_type'=>ACTIVE_TYPE_1));
  		$product_data = array();
  		foreach($product_card_list as $k=>$v){
  			$product_data[$v['unit']][$v['id']]=$v;
  		}

  		ksort($product_data);
  		$data['product'][PRODUCT_TYPE_2] = $product_data;
  		
  		$product_active_list = $productDao->searchList(array('type'=>PRODUCT_TYPE_2,'status'=>PRODUCT_STATUS_1,'active_type'=>ACTIVE_TYPE_2));
  		$product_data = array();
  		
  		$targetCourse = Common::_t('target_course');
  		foreach($product_active_list as $k=>&$v){
  			$v['target_course_name'] = $targetCourse[$v['target_course']];
  			$product_data[$v['unit']][$v['id']]=$v;
  		}
  		ksort($product_data);
  		$data['product']['active_class'] = $product_data;
  		  		
		$productReturnTicketList = $productDao->searchList(array('type'=>PRODUCT_TYPE_3,'status'=>PRODUCT_STATUS_1));
		$data['returnTicketPair'] = Common::fetchPairOfList('id', 'price', $productReturnTicketList);
		return $data;
	}
	public function updatePassword(){
		return  $this->userPublic();
	}
	public function subUpdatePassword(){
		$tmp = HttpServerManager::getUserServer()->updatePassword($_SESSION['user']['email'],$_POST['oldPassword'], $_POST['newPassword']);
		if ($tmp===true){
			$msg = Common::_t('msg');
			ClassManager::getToos()->msgbox($msg[MESSAGE_TYPE_7],'user_updatePassword.htm');
		}
		else{
			$msg = Common::_t('user_error');
			ClassManager::getToos()->msgbox($msg[$tmp]);
		}
	}
	public function buy(){
		$product_id = isset($_POST['id'])?$_POST['id']:DEFAULT_SELECT;
		$userKind = USER_KIND_NORMAL;//若再次购买页将会更新USER_KIND
		if($_REQUEST['type']=='orderHot'){
			$pid = $_REQUEST['pid'];
			if(isset($pid)&&intval($pid)>0){
				$product_id=array($pid);
			}
			$productInfo = HttpDaoManager::getProductDao()->get($pid);
			if(empty($productInfo)){
				header('location:hotbox.htm');			
			}else{
				$activeType = $productInfo['active_type'];
				if($activeType!=ACTIVE_TYPE_1){//定向制定USER_KIND
					$userKind = $productInfo['target_course'];//定向活动，只定向一种
				}
			}
		}

		$initUrl = array('left'=>'user_productList.htm');
		$data = $this->userPublic($initUrl);
		$data['product'] = array();
		$data['sumPrice'] = 0;
		$data['sumDiscount'] = 0;
		$data['voucher'] = array();
		$product_type_list = array();
		if(!empty($product_id)){
			$data['productId'] = implode(',',$product_id);
			$data['product'] = HttpDaoManager::getProductDao()->getListInId($data['productId']);
			$product_type_list = Common::array_value_list($data['product'], 'type');
			$data['sumPrice'] = HttpDaoManager::getProductDao()->getSumPrice($data['productId']);
			$data['sumDiscount'] = HttpDaoManager::getProductDao()->getSumDiscount($data['productId']);
			$data['voucher'] = HttpServerManager::getTicketServer()->getVoucher($_SESSION['user']['id']);
		}
		$data['monthly_product_flg'] = false;

		if(!empty($product_type_list)){
			if(in_array(PRODUCT_TYPE_1,$product_type_list)){
				$data['monthly_product_flg'] = true;
				$data['monthly_start_date'] = date("Y-m-d",strtotime("+ 1 day"));
			}
		}
		$data['userKind'] = $userKind;
		return  $data;
	}
	
	public function done(){
		if (isset($_GET['orderId'])){
			$order = HttpServerManager::getOrderServer()->userGetByid($_GET['orderId'], $_SESSION['user']['id']);
		}else{
			if(!isset($_POST['product_id'])){
				header('location:user_productList.htm');
			}
			$buy_info = array();
			$buy_info['productId'] = $_POST['product_id'];
			$buy_info['userId'] = $_SESSION['user']['id'];
			$buy_info['use_number'] = $_POST['use_number'];
			$buy_info['monthly_start_date'] = 0;
			
			if(isset($_POST['monthly_start_date'])){
				$buy_info['monthly_start_date'] = strtotime($_POST['monthly_start_date']);
			}
			$order = HttpServerManager::getOrderServer()->buy($buy_info);
			
			$user_info = array();
			$user_info['user_kind'] = $_POST['userKind'];
			HttpDaoManager::getUserDao()->update($user_info, $_SESSION['user']['id']);
		}
		//进行二次转发，防止二次提交
		header('location:user_payready.html?orderId='.$order['orderId']);
	}
	
	public function payready(){
		if (isset($_GET['orderId'])){
			$order = HttpServerManager::getOrderServer()->userGetByid($_GET['orderId'], $_SESSION['user']['id']);//预防用户手动改变OrderID
		}
		if (is_array($order)){
			$userData = HttpDaoManager::getUserDao()->get($_SESSION['user']['id']);
			$data['realPay'] = $order['realPay'];
			$data['user_moeny'] = $userData['user_moeny'];
			$data['id'] = $order['orderId'];
			if($data['realPay']<=0){
				$msg = Common::_t('user_error');
				ClassManager::getToos()->msgbox($msg[USER_ERROR_THREE],'user_home.htm');
			}
		}else{
			$msg = Common::_t('user_error');
			ClassManager::getToos()->msgbox($msg[USER_ERROR_THREE],'user_home.htm');		
		}
		$initUrl = array('left'=>'user_productList.htm');
		return array_merge($this->userPublic($initUrl),$data);
	}
	
	public function alreadyBooking(){
		$userBook_filter = array();
		$userBook_filter['user_id'] = $_SESSION['user']['id'];
		$userBook_filter['class_status'] = array(CLASS_STATUS_3,'<>');
		$userBook_filter['book_date'] =array(strtotime(date('Y-m-d')),'>=');
		$data['list'] =  HttpServerManager::getBookCourseServer()->userBook($userBook_filter);
		return  array_merge($data, $this->userPublic());
	}
	public function have($list){
		$time = Common::getTimes();
		$bookType = Common::_t('book_types');
		
		$class_status_pair = Common::_t('class_status');
		foreach($class_status_pair as $key=>$value){
			if($key==CLASS_STATUS_0||$key==CLASS_STATUS_1){
				$class_status_pair[$key]='上课准备中';
			}
		}
		
		$courseDao = HttpDaoManager::getCourseDao();
		$teacherDao  = HttpDaoManager::getTeacherDao();
		$bookCourseEvaluationDao = HttpDaoManager::getBookCourseEvaluationDao();
		foreach ($list as $k=>$v){
			$list[$k]['evaluation_id']='';
			$tmp = $time[$v['book_time']];
			$list[$k]['book_time'] = $tmp['name'].'-'.$tmp['nextName'];
			$list[$k]['book_type'] = $bookType[$v['book_type']];
			$courseData  = $courseDao->get($v['course_id']);
			$list[$k]['course'] = $courseData['theme'];
			$list[$k]['course_id'] = $courseData['id'];
			
			$book_start_time = strtotime(date('Y-m-d',$v['book_date']).' '.$tmp['name'].':00');
			$book_end_time = strtotime(date('Y-m-d',$v['book_date']).' '.$tmp['nextName'].':00');
			
			$list[$k]['class_status_name'] = $class_status_pair[$v['class_status']];
			if($v['class_status']==CLASS_STATUS_0||$v['class_status']==CLASS_STATUS_1){
				if(time()>$book_end_time){
					$list[$k]['class_status_name'] = '超时未上课';
				}
			}
			
			$list[$k]['download_url'] = HttpServerManager::getBookCourseServer()->downloadUrl($v['course_id'], $v['chapter_id']);	
					
			$teacherData = $teacherDao->get($v['teacher_id']);
			$list[$k]['teacher'] = $teacherData['name'];
			$list[$k]['teacher_portrait'] = $teacherData['detail_portrait'];
			$list[$k]['teacher_qq'] = $teacherData['qq'];
			$list[$k]['teacher_skype'] = $teacherData['skype'];
			$list[$k]['teacher_id'] = $teacherData['id'];
			$bookCourseEvaluation = $bookCourseEvaluationDao->searchData(array('book_course_id'=>$v['id']));
			if (empty($bookCourseEvaluation)){
				$list[$k]['satisfaction']= 0;
			}
			else{
				$list[$k]['evaluation_id']= $bookCourseEvaluation['id'];
				$list[$k]['satisfaction']= $bookCourseEvaluation['satisfaction'];
			}
			
		}
		$data['list'] = $list;
		$data['complaint_type'] = Common::_t('complaint_type');
		return $data;
	}
	
	public function haveClassRecord(){
		$where = $_GET;
		$where['user_id'] = $_SESSION['user']['id'];
		$where['class_status'] = CLASS_STATUS_2;
		$data = HttpServerManager::getBookCourseServer()->pagingBySearch($where,"",5);
		
		$tmp =  $this->have($data['list']);
		$data['list'] = $tmp['list'];
		$data['complaint_type'] = $tmp['complaint_type'];
		$data['start_book_date'] = Common::getGetStrValue('start_book_date');
		$data['end_book_date'] =  Common::getGetStrValue('end_book_date');
		
		return  array_merge($data, $this->userPublic());
	}
	public function financing(){
		$page_search = array();
		$page_search['page_par']='tpage';
		$ticket = HttpServerManager::getTicketServer()->pagingBySearch(array('receive_user_id'=>$_SESSION['user']['id']),'',10,$page_search);
		$status = Common::_t('ticket_status'); 
		$time = time();
		$productDao = HttpDaoManager::getProductDao();
		foreach ($ticket['list'] as $k=>$v){
			$productData = $productDao->get($v['product_id']);
			$ticket['list'][$k]['price'] = $productData['price'];
			if ($v['valid_end_time']<=$time){
				$ticket['list'][$k]['status'] = $status[TICKET_STATUS_5];
			}
			else{
				$ticket['list'][$k]['status'] = $status[$v['status']];
			}
		}
		$pay_type_list=Common::_t('pay_type');
		$page_search = array();
		$page_search['page_par']='opage';
		$order  = HttpServerManager::getOrderServer()->pagingBySearch(array('user_id'=>$_SESSION['user']['id']),'',10,$page_search);
		$payStatus = Common::_t('pay_status');
		$productIdArray = array();
		foreach ($order['list'] as $k=>$v){
			$tmp =  strtr($v['product_id'],array('|'=>''));
			$tmp1  =  explode(',',$tmp);
			$order['list'][$k]['product_id']= $tmp1;
			$productIdArray  = array_merge($productIdArray,$tmp1);
			if ($v['pay_time']==0){
				$order['list'][$k]['pay_time'] = '没有支付';
				$order['list'][$k]['pay_type_name']= '无';
			}
			else{
				$order['list'][$k]['pay_time']= date('Y-m-d H:i:s',$v['pay_time']);
				$order['list'][$k]['pay_type_name']= $pay_type_list[$v['pay_type']];
			}
		}
		$products = array();
		if(!empty($productIdArray)){
			$product = HttpDaoManager::getProductDao()->getListInId(implode(',', $productIdArray));
			foreach ($product as $v){
				$products[$v['id']]=  $v['name'].'('.$v['period_validity'].'天有效)';
			}
		}
		
		
		return array_merge(array('ticket'=>$ticket,'order'=>$order,'product'=>$products,'payStatus'=>$payStatus), $this->userPublic());
	}
	
	public function updateUserInfo(){
		$user_book_info  =""; 
		$userId = $_SESSION['user']['id'];
// 		$where = array('user_id'=>$userId,'class_status'=>array(CLASS_STATUS_3,'!='));
// 		$order = 'order by id desc ';
// 		$limit = 1;
// 		$data_last_list =HttpDaoManager::getBookCourseDao()->searchList($where,$order, $limit);
// 		$data_last_info = $data_last_list['0'];
		
// 		$qq = "";
// 		$phone = "";
// 		$skype_id = "";
// 		if(!empty($data_last_info)){
// 			if(isset($data_last_info['qq'])&&$data_last_info['qq']!=""){
// 				$qq = $data_last_info['qq'];
// 			}	
// 			if(isset($data_last_info['phone'])&&$data_last_info['phone']!=""){
// 				$phone = $data_last_info['phone'];
// 			}	
// 			if(isset($data_last_info['skype_id'])&&$data_last_info['skype_id']!=""){
// 				$skype_id = $data_last_info['skype_id'];
// 			}	
// 		}

		$userInfo = HttpDaoManager::getUserDao()->get($userId);
		if(isset($userInfo['qq'])&&$userInfo['qq']!=""){
			$qq = $userInfo['qq'];
		}	
		if(isset($userInfo['phone'])&&$userInfo['phone']!=""){
			$phone = $userInfo['phone'];
		}	
		if(isset($userInfo['skype_id'])&&$userInfo['skype_id']!=""){
			$skype_id = $userInfo['skype_id'];
		}	
		
		$userInit = array();
		$userInit['qq'] = $qq;
		$userInit['phone'] = $phone;
		$userInit['skype_id'] = $skype_id;
		$userInit['english_name'] = $userInfo['english_name'];
		$userInit['real_phone'] = $userInfo['real_phone'];
		$userInit['email'] = $userInfo['email'];

		return array_merge(array('userInit'=>$userInit),$this->userPublic());
	}
	
	public function sendCode(){
		$phone= $_GET['phone'];
		$sms_result = array();
		$where = array();
		$where['phone'] = $phone;
		$where['real_phone'] = 2;
		$user_info = HttpDaoManager::getUserDao()->searchList($where);
		if(!empty($user_info)){
			if($user_info[0]['id']!==$_SESSION['user']['id']){
				$sms_result['success'] = 'fail_duplicate';
				exit(json_encode($sms_result));
			}
		}
		$sms_send = HttpServerManager::getUserServer()->sendCode($phone);
		$sms_result = array('success'=>$sms_send);
		exit(json_encode($sms_result));
	}
	
	public function subUpdateUserInfo(){
		HttpDaoManager::getUserDao()->update($_POST, $_SESSION['user']['id']);
		$msg = Common::_t('msg');
		ClassManager::getToos()->msgbox($msg[MESSAGE_TYPE_7]);
	}
	public function balancePay(){
		$tmp = HttpServerManager::getOrderServer()->balancePay($_POST['id'],$_SESSION['user']['id']);
		if ($tmp===TRUE){
			$msg = Common::_t('msg');
			header('location:user_paysuccess.html');
		}
		else{
			$msg = Common::_t('user_error');
			ClassManager::getToos()->msgbox($msg[$tmp]);
		}

	}
	/**
	 * 站内信列表
	 * @return multitype:
	 */
	public function letterStationList(){
		$letterStationDao = HttpDaoManager::getLetterStationDao();
		$letterStationList = $letterStationDao->getList(array('user_id'=>$_SESSION['user']['id']));
		$count = $letterStationDao->count(array('user_id'=>$_SESSION['user']['id'],'status'=>STATION_STATUS_0));
		return array_merge(array('letterStationList'=>$letterStationList,'count'=>$count), $this->userPublic()) ;
	}
	/**
	 * 站内信内容
	 * @return multitype:
	 */
	public function letterStationInfo(){
		$letterStationDao = HttpDaoManager::getLetterStationDao();
		$data = $letterStationDao->get($_GET['id']);
		HttpServerManager::getLetterStationServer()->markRead($_GET['id']);
		return array_merge($data,$this->userPublic());
	}
	/**
	 * 充值
	 * @return string
	 */
	public function topUp(){
		return $this->userPublic();
	}
	
	public function subVerifyCode(){
		$data = array();
		$code= $_GET['code'];
		$phone = $_GET['phone'];
		
		$result = array();
		$where = array();
		$where['phone'] = $phone;
		$where['real_phone'] = 2;
		$user_info = HttpDaoManager::getUserDao()->searchList($where);
		if(!empty($user_info)){
			if($user_info[0]['id']!==$_SESSION['user']['id']){
				$result['success'] = 'fail_duplicate';
				exit(json_encode($result));
			}
		}
		
		$data['code'] = $code;
		$data['phone'] = $phone;
		$ret_code = HttpServerManager::getUserServer()->userUpdate($data, $_SESSION['user']['id']);
		if($ret_code ===true){
			$result['success'] = $ret_code;
		}else{
			$result['false'] = 'fail';
			$result['code'] = $ret_code;
		}
		 exit(json_encode($result));
	}
	
	public function verifyDuplicatePhone(){
		$data = array();
		$phone = $_GET['phone'];
		
		$result = array();
		$where = array();
		$where['phone'] = $phone;
		$user_info = HttpDaoManager::getUserDao()->searchList($where);
		if(!empty($user_info)){
			if($user_info[0]['id']!==$_SESSION['user']['id']){
				$result['user_info_id'] = $user_info[0]['id'];
				$result['session_user_id'] = $_SESSION['user']['id'];
				$result['success'] = 'fail_duplicate';
				exit(json_encode($result));
			}
		}	

		$result = array();
		$result['success'] = 'success';
		exit(json_encode($result));
	}
	
	public function getUserInfo(){
		$data = array();
		$user_info = HttpDaoManager::getUserDao()->get($_SESSION['user']['id']);
		exit(json_encode($user_info));
	}
	/**
	 * 提交充值
	 */
	public function subTopUp(){
		$tmp  = HttpServerManager::getTicketServer()->TicketTopUp($_SESSION['user']['id'], $_POST['number'], $_POST['password']);
		if ($tmp===true){
			$msg = Common::_t('msg');
			ClassManager::getToos()->msgbox($msg[MESSAGE_TYPE_9]);
		}
		else{
			$msg = Common::_t('user_error');
			ClassManager::getToos()->msgbox($msg[$tmp]);
		}
	}
	/**
	 * 汇款
	 */
	public function remittance(){
		$tmp = HttpServerManager::getOrderServer()->remittance($_POST['id'], $_SESSION['user']['id']);
		if ($tmp===true){
			$msg = Common::_t('msg');
			header('location:user_payremit.htm');
		}
		else{
			$msg = Common::_t('user_error');
			ClassManager::getToos()->msgbox($msg[$tmp]);
		}
	}
	/**
	 * 会员老师列表
	 * @return multitype:
	 */
	public function teacherList(){
		$data = HttpServerManager::getTeacherServer()->lists();
		return array_merge($data,$this->userPublic());
	}
	
	/**
	 * 定制服务
	 * @return multitype:
	 */
	public function customService(){
		$userData = HttpDaoManager::getUserDao()->get($_SESSION['user']['id']);
		return  array_merge($userData,$this->userPublic());
	}
	/**
	 * 订短信
	 */
	public function customSMS(){
		HttpServerManager::getUserServer()->customSMS($_SESSION['user']['id']);
		ClassManager::getToos()->msgbox(Common::_t('custom_success'));
	}
	/**
	 * 退订短信
	 */
	public function notCustomSMS(){
		HttpServerManager::getUserServer()->notCustomSMS($_SESSION['user']['id']);	
		ClassManager::getToos()->msgbox(Common::_t('unsubscribe_success'));
	}
	/**
	 *邀请
	 */
	public function invitation(){
		$invitationUrl = $_SERVER['SERVER_NAME'].'/userInvitation.html?invitation_user_id='.$_SESSION['user']['id'];
		return array_merge(array('invitation'=>$invitationUrl),$this->userPublic());
	}
	/**
	 * 积分
	 */
	public function integral(){
		$data['ticket'] = HttpDaoManager::getProductDao()->searchList(array('type'=>PRODUCT_TYPE_3,'status'=>PRODUCT_STATUS_1));
		$data['user'] = HttpDaoManager::getUserDao()->get($_SESSION['user']['id']);
		$data['integralType'] = Common::_t('integral_type');
		$data['integralLog'] = HttpServerManager::getUserIntegralLogServer()->pagingBySearch(array('user_id'=>$_SESSION['user']['id']),'order by id desc ');
		return array_merge($data,$this->userPublic());
	}
	/**
	 * 服务
	 */
	public function service(){
		return $this->userPublic();
	}
	/**
	 *留言 
	 */
	public function message(){
		return $this->userPublic();
	}
	public function subMessage(){
		$data = $_POST;
		$data['user_id'] = $_SESSION['user']['id'];
		$data['add_time'] = time();
		HttpDaoManager::getMessageDao()->add($data);
		$msg = Common::_t('msg');
		ClassManager::getToos()->msgbox($msg[MESSAGE_TYPE_10]);
	}
	public function collectionList(){
		$list  = HttpServerManager::getCollectionServer()->getCollectoinTeacherList($_SESSION['user']['id']);
		return array_merge(array('list'=>$list),$this->userPublic());
	}
	public function englishCorner(){
		$data = $this->userPublic() ;
  		$data['course1'] =  HttpDaoManager::getCourseTypeDao()->searchList(array('type'=>COURSE_TYPE_TYPE_1));
  		$data['course2'] =  HttpDaoManager::getCourseTypeDao()->searchList(array('type'=>COURSE_TYPE_TYPE_2));
  		$data['course3'] =  HttpDaoManager::getCourseTypeDao()->searchList(array('type'=>COURSE_TYPE_TYPE_3));
  		$data['course4'] =  HttpDaoManager::getCourseTypeDao()->searchList(array('type'=>COURSE_TYPE_TYPE_4));
  		$data['course5'] =  HttpDaoManager::getCourseTypeDao()->searchList(array('type'=>COURSE_TYPE_TYPE_5));
		$data['courseType'] = Common::_t('course_type');
		return  $data ;
	}
	public function evaluation(){
		$data = $_POST;
		$data['user_id'] = $_SESSION['user']['id'];
		HttpServerManager::getBookCourseEvaluationServer()->evaluation($data);
		$msg = Common::_t('msg');
		ClassManager::getToos()->msgbox($msg[MESSAGE_TYPE_11]);				
	}
	public function complaint(){
		$data = $_POST;
		$data['user_id'] = $_SESSION['user']['id'];
		HttpServerManager::getComplaintServer()->complaint($data);
		$msg = Common::_t('msg');
		ClassManager::getToos()->msgbox($msg[MESSAGE_TYPE_12]);
	}
	public function getCourseRecord(){
		$data = $_POST;
		$res_info = HttpDaoManager::getCourseRecordDao()->getByBookCourseId($data['id']);
		exit(json_encode($res_info));
	}	
	public function updateBooking(){
		$userData = HttpDaoManager::getUserDao()->get($_SESSION['user']['id']);
		$data = $this->userPublic();

		$bookingData = HttpDaoManager::getBookCourseDao()->get($_GET['id']);
		$data['message'] = $bookingData['message'];
		$data['teacher'] = HttpDaoManager::getTeacherDao()->get($bookingData['teacher_id']);
		$data['course_type'] = Common::_t('course_type');
		$data['select_course_type'] = $bookingData['course_type'];
		$data['select_course'] = $bookingData['course_id'];
		$data['select_chapter'] = $bookingData['chapter_id'];
		$communication = Common::_t('user_communication');
		$data['communicationOption'] = page_modifier_options($communication,$bookingData['communication_tools']);
		$data['date'] = date('Y年m月d日',$bookingData['book_date']);
		$time = Common::getTimes();
		$data['time']=$time[$bookingData['book_time']]['name'].'-'.$time[$bookingData['book_time']]['nextName'];
		
		return $data;
	}
	public function subUpdateBooking(){
		$data = $_POST;
		if (empty($data['course_type_radio'])){
			unset($data['course_type_radio']);
		}
		$updateData = array();
		$updateData['course_id'] = $data['course_id'];
		$updateData['chapter_id'] = $data['chapter_id'];
		$updataData['id'] =  $data['id'];
		$chapter_name = "";
		if(isset($updateData['chapter_id'])&&$updateData['chapter_id']>0){
			$chapter_info = HttpDaoManager::getChapterDao()->get($updateData['chapter_id']);
			$updateData['course_id'] = $chapter_info['course_id'];
			if(isset($updateData['course_id'])&&$updateData['course_id']>0){
				$course_info = HttpDaoManager::getCourseDao()->get($updateData['course_id']);
				$updateData['course_name'] = $course_info['theme'];
				$updateData['course_type'] = $course_info['type'];
			}			
			$updateData['chapter_no'] =  $chapter_info['chater_no'];//写错了
			$chapter_name = $chapter_info['name'];
			$updateData['chapter_name'] = Common::getLangPostValue($chapter_info['name'],$chapter_info['english_name']);
		}
		
		HttpDaoManager::getBookCourseDao()->update($updateData, $updataData['id']);
// 		if (Common::getPostStrValue('default')=='1'){
// 			$userData['default_communication'] = Common::getPostStrValue('communication_tools');
// 			HttpDaoManager::getUserDao()->update($userData, $_SESSION['user']['id']);
// 		}
		$result = array();
		$result['success'] = 'success';
		$result['course_chapter_name'] = $updateData['course_name'].'-'.$updateData['chapter_name'];
		exit(json_encode($result));
	}
	public function exchange(){
		$tmp =  HttpServerManager::getUserServer()->exchange($_GET['id'], $_SESSION['user']['id']);
		if ($tmp ===true){
			$msg = Common::_t('msg');
			ClassManager::getToos()->msgbox($msg[MESSAGE_TYPE_13]);
		}
		else{
			$msg = Common::_t('user_error');
			ClassManager::getToos()->msgbox($msg[$tmp]);
		}
	}
	
	public function chargePay(){
		$orderServer = HttpServerManager::getOrderServer();
		$charge_money =$_POST['charge_money'];
		$pay_type_value = $_POST['bank_type_value'];
		
		$data = array();
		$data['online_money'] = $charge_money;
		if ($pay_type_value==PAY_TYPE_ALIPAY){
			$html = $orderServer->alipayCharge($data);
			exit ($html);
		}else{
			$data['bank_type']= $pay_type_value;
			$html = $orderServer->tenpayCharge($data);//其余全部是财付通
			exit ($html);
		}
	}
	
	public function onlinePay(){
		$orderData  = HttpDaoManager::getOrderDao()->get($_POST['id']);
		$orderServer = HttpServerManager::getOrderServer();
		$userId = $_SESSION['user']['id'];
		$tmp="";
		if(!empty($_POST['user_moeny'])){
			$orderData['pay_type'] =PAY_TYPE_BALANCE; 
			$orderData['money'] =$_POST['user_moeny']; 
			$tmp = $orderServer->validBalancePaySome($_POST['user_moeny'], $_POST['id'], $userId);//先进行余额支付
			HttpServerManager::getPayLogServer()->addForOrder($orderData);
		}
		$pay_type_value = $_POST['bank_type_value'];
		
		$orderData['pay_type'] = $pay_type_value;
		$orderData  = HttpDaoManager::getOrderDao()->get($_POST['id']);
		if ($tmp ==BALANCE_PAY_SUCCESS||empty($_POST['user_moeny'])){//余额支付成功或者余额为0，全部在线支付
			if ($pay_type_value==PAY_TYPE_ALIPAY){
				$html = $orderServer->alipay($orderData);		
				exit ($html);
			}else{//Default cft
				$orderData['bank_type']= $pay_type_value;
				$html = $orderServer->tenpay($orderData);
				exit ($html);
			}
		}else{
			$msg = Common::_t('user_error');
			ClassManager::getToos()->msgbox($msg[$tmp]);
		}
	}
	
	public function respond(){
		$pay_log_id  = $_GET['pay_log_id'];
		$pay_type = $_GET['code'];
		if($_GET['code']==PAY_TYPE_ALIPAY){//支付宝
			$alipay  = new Alipay();
			$data = $_GET;
			$trade_status = $alipay->returnUrl($data);
			if($trade_status==TRUE){
				$payInfo = array();
				$payInfo['pay_log_id'] = $pay_log_id;
				$payInfo['id'] = $_GET['out_trade_no'];
				$payInfo['total_fee'] = $_GET['total_fee'];
				$payInfo['pay_type'] = $pay_type;
				$return_mes = HttpServerManager::getOrderServer()->updatePayInfo($payInfo);
				if($return_mes !=true){
					ClassManager::getToos()->msgbox($return_mes);
				}else{
					ClassManager::getToos()->msgbox('支付成功','user_home.htm');
				}
			}else{
				ClassManager::getToos()->msgbox('支付失败','user_home.htm');
			}
		}
		
		if($_GET['code']==PAY_TYPE_TENPAY){//支付宝
			$tenpay  = new Tenpay();
			unset($_GET['module']);
			unset($_GET['control']);
			unset($_GET['pay_log_id']);
			unset($_GET['code']);
			$data = $_GET;
			$trade_status = $tenpay->returnUrl($data);
			if($trade_status==TRUE){
				$payInfo = array();
				$payInfo['pay_log_id'] = $pay_log_id;
				$payInfo['id'] = $_GET['out_trade_no'];
				$payInfo['total_fee'] = $_GET['total_fee'];
				$payInfo['pay_type'] =$pay_type;
				$return_mes = HttpServerManager::getOrderServer()->updatePayInfo($payInfo);
				if($return_mes !=true){
					ClassManager::getToos()->msgbox($return_mes);
				}else{
					ClassManager::getToos()->msgbox('支付成功','user_home.htm');
				}
			}else{
				ClassManager::getToos()->msgbox('支付失败,若有疑问,请联系我们','user_home.htm');
			}
		}
		ClassManager::getToos()->msgbox('支付成功','user_home.htm');
	}
	
	public function paysuccess(){
		$pay_order_type  = $_SESSION['pay_order_type'];
		if(empty($_SESSION['pay_order_type'])){
			header("location:".SITE_URL.'user_home.htm');
			exit;
		}
		$successData = array();
		if($pay_order_type==ORDER){
			$pay_order_id = $_SESSION['pay_order_id'];
			if(intval($pay_order_id)<0){
				ClassManager::getToos()->msgbox('支付失败,若有疑问,请联系我们','user_home.htm');
			}
			$pay_order_info = HttpDaoManager::getOrderDao()->get($pay_order_id);
			if(empty($pay_order_info)){
				ClassManager::getToos()->msgbox('支付失败,若有疑问,请联系我们','user_home.htm');
			}	
			if($pay_order_info['pay_status']!=PAY_STATUS_2){
				ClassManager::getToos()->msgbox('支付失败,若有疑问,请联系我们','user_home.htm');
			}
			
			$where = array();
			$order_by = 'order by recommend desc';
			$limit = 2;
			$teacher_list = HttpDaoManager::getTeacherDao()->searchList($where,$order_by,$limit);
			$successData['type'] = ORDER;
			$successData['teacher_list'] = $teacher_list;
		}
		
		if($pay_order_type==SAVING){
			$pay_order_id = $_SESSION['pay_order_id'];
			if(intval($pay_order_id)<0){
				ClassManager::getToos()->msgbox('充值失败,若有疑问,请联系我们','user_home.htm');
			}
			$pay_order_info = HttpDaoManager::getPayLogDao()->get($pay_order_id);
			if(empty($pay_order_info)){
				ClassManager::getToos()->msgbox('充值失败,若有疑问,请联系我们','user_home.htm');
			}	
			if($pay_order_info['status']!=PAY_STATUS_CONFIRMED){
				ClassManager::getToos()->msgbox('充值失败,若有疑问,请联系我们','user_home.htm');
			}
			
			$where = array();
			$order_by = 'order by recommend desc';
			$limit = 2;
			$teacher_list = HttpDaoManager::getTeacherDao()->searchList($where,$order_by,$limit);
			$successData['type'] = SAVING;
			$successData['teacher_list'] = $teacher_list;
		}
		
		unset($_SESSION['pay_order_id']);
		unset($_SESSION['pay_order_type']);
		return array_merge($this->userPublic(),$successData);
	}
	
	public function payremit(){
		return $this->userPublic();
	}	
	
	public function booksuccess(){
		$book_course_id = $_SESSION['book_course_id'];
		if(intval($book_course_id)<0){
			header('location:user_home.htm');
		}
		$book_course_info = HttpDaoManager::getBookCourseDao()->get($book_course_id);
		if(empty($book_course_info)){
			header('location:user_home.htm');
		}	
		$course_info = HttpDaoManager::getCourseDao()->get($book_course_info['course_id']);
		$teacher_info = HttpDaoManager::getTeacherDao()->get($book_course_info['teacher_id']);
		$successData = array();
		$successData['chapter_name'] = $course_info['theme'].'-'.getLangStr($book_course_info['chapter_name'],'zh_cn');
		$book_time_array = Common::getTimes();
		$book_time_start  = $book_time_array[$book_course_info['book_time']]['name'];
		$book_time_end  = $book_time_array[$book_course_info['book_time']]['nextName'];
		$successData['date_time'] = date('Y-m-d',$book_course_info['book_date']);
		$successData['start_time'] = $book_time_start;
		$successData['end_time'] = $book_time_end;
		$successData['english_name'] = $book_course_info['english_name'];
		$successData['teacher_name'] = $teacher_info['name'];
		$successData['teacher_portrait'] = $teacher_info['detail_portrait'];
		$successData['course_type'] = $book_course_info['course_type'];
		$successData['course_id'] = $book_course_info['course_id'];
		$successData['chapter_id'] = $book_course_info['chapter_id'];
		$successData['skype'] = $teacher_info['skype'];
		$successData['qq'] = $teacher_info['qq'];
		$successData['download_url'] = HttpServerManager::getBookCourseServer()->downloadUrl($book_course_info['course_id'],$book_course_info['chapter_id']);
		unset($book_course_id);
		return array_merge($this->userPublic(55),$successData);
	}
	
	public function clearFrontOrder(){
		$front_order_status = $_POST['front_order_status'];
		$resut = array();
		if($front_order_status=='front_order_complete'){
			unset($_SESSION['user']);
			$result['success']='success';
		}
		$result['success']='failure';
		exit(json_encode($result));
	}
}
?>